import request from '@/utils/request'

export function login(type, mobile, password) {
  const data = {
    type,
    mobile,
    password
  }
  return request({
    url: '/login',
    method: 'post',
    data
  })
}

export function logout() {
  return request({
    url: '/login/logout',
    method: 'post'
  })
}

export function forgetPwd(type, mobile, password) {
  const data = {
    type,
    mobile, 
    password
  }
  return request({
    url: '/forgetPassword',
    method: 'post',
    data
  })
}

export function getVerifyCode(mobile, type) {
  return request({
    baseURL: 'http://test.zhangqingxi.cn/demo/sms',
    url: '/getFoundPasswordCode',
    method: 'get',
    params: { mobile }
  })
}

export function getUserInfo (type, userId) {
  return request({
    url: '/userInfo',
    method: 'get',
    params: { type, id: userId }
  })
}

export function register (mobile, password) {
  const data = {
    mobile,
    password
  }
  return request({
    url: '/register',
    method: 'post',
    data
  })
}


export function getRegisterCode (mobile, type) {
  return request ({
    baseURL: 'http://test.zhangqingxi.cn/demo/sms',
    url: '/getRegisterCode',
    method: 'get',
    params: {mobile, type}
  })
}